#include <iostream>
#include <vector>
#include <unordered_map>
#include <cstring>
#include <cmath>
using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
#define endl '\n'
const int N = 2e5 + 10;
string ans;
int n;


void dfs(int pos, int a, int b, string s)
{
    if (pos == n)
    {
        if (s > ans)
        {
            ans = s;
        }
        return;
    }
    
    int up = '9' - s[pos], down = s[pos] - '0' + 1;
    if (up <= a || down <= b)
    {
        // 如果可以变成9，就都尝试一下
        s[pos] = '9';
        if(up <= a) dfs(pos + 1, a - up, b, s);
        if(down <= b) dfs(pos + 1, a, b - down, s);
    } 
    else 
    {
        // 两种操作都不能使该位置变为9，把操作1用完
        s[pos] += a;
        dfs(pos + 1, 0, b, s);
    }
}

void solve()
{
    string s; int a, b; cin >> s >> a >> b;
    n = s.size();
    dfs(0, a, b, s);
    cout << ans << endl;
}

int main()
{
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int T = 1;
    // cin >> T;
    while (T--)
    {
        solve();
    }
    return 0;
}